package com.xiangyang.pos.http;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Created by Administrator on 2017/1/4.
 */
public class RequestParametersXML {
    private Map<String, String> requestMap = new HashMap<>();

    public void put(String key, String value) {
        requestMap.put(key, value);
    }

    public String buildRequestString() {
        Set<Map.Entry<String, String>> entries = requestMap.entrySet();
        Iterator<Map.Entry<String, String>> iterator = entries.iterator();
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("<xml>");
        while (iterator.hasNext()) {
            Map.Entry<String, String> entry = iterator.next();
            stringBuffer.append("<"+entry.getKey() + ">" + entry.getValue() + "</"+entry.getKey() + ">");
        }
        stringBuffer.append("</xml>");
        return stringBuffer.toString().substring(0, stringBuffer.toString().length() - 1);
    }
}
